/*
 * @Author: 六弦(melodyWxy)
 * @Date: 2022-03-01 14:28:12
 * @LastEditors: 六弦(melodyWxy)
 * @LastEditTime: 2022-03-01 15:38:22
 * @FilePath: /menorepo-demo/Users/wxy/codeWorks/up/d_form/antd-demo-ts/src/pages/AddForm/index.tsx
 * @Description: update here
 */

import { Steps } from "antd";
import { FC, Component } from "react";
import Step0 from "./Step0";
import Step1 from "./Step1";
import Step2 from "./Step2";


import type { AddFormState } from './type';

const { Step } = Steps;

class AddForm extends Component<{}, AddFormState> {
  state = {
    step: 0,
    schema: {
        btns: [{
            submit: true,
        }]
    }
  };

  stepNext = (value: Record<string, any>) => {
      console.log('value', value);
    this.setState((preState)=>({
        schema: {
            ...preState.schema,
            ...value
        },
        step: preState.step + 1
    }), ()=> {
        console.log('this.state', this.state);
    })
   
  }

  render() {
    const { step, schema } = this.state;
    return (
      <div>
        <Steps current={step}>
          <Step title="创建表单" />
          <Step title="创建子项" />
          <Step title="发布预览" />
        </Steps>
        {step === 0 && <Step0  stepNext={this.stepNext}/>}
        {step === 1 && <Step1 stepNext={this.stepNext}/>}
        {step === 2 && <Step2  schema={schema}/>}
      </div>
    );
  }
}

export default AddForm;
